#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import json
import plotly.graph_objects as go

# 读取geojson数据
with open('data.json') as f:
    text = f.read()
geo = json.loads(text)
# 轨迹
map = go.Scattermapbox(
    mode = "markers",
    lon = [121.4853572845459], lat = [31.199660769915113],
    marker = {'size': 20, 'color': ["cyan"]})
# 画布
fig = go.Figure(map)
# 更新样式 给mapbox添加一个图层
fig.update_layout(
    mapbox = {
        'style': "stamen-terrain",
        'center': { 'lon':121.4853572845459, 'lat': 31.199660769915113},
        'zoom': 15, 'layers': [{
            'source': geo,
            'type': "fill", 'below': "traces", 'color': "royalblue","opacity":0.5}]},
    margin = {'l':0, 'r':0, 'b':0, 't':0})
# 显示画布
fig.show()
